﻿/*
 
Celerity: Sensory Overload
Copright 2012 by Adam Hill, David Gannon, Thomas Tamblyn & Patrick Ytting
Contact: adam.hill@outlook.com
Website: adamhill.org
Licence: MS-Pl Licence
  
 */

using Celerity.Audio;
using Celerity.CV;
using Celerity.Input;
using Celerity.Logic;
using Celerity.UI;
using Celerity.Util;
using Celerity.World;
using Emgu.CV.Structure;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace Celerity
{
    public partial class CelerityGame : Game
    {
        #region Input Variables
        //Graphics Device & Sprite Batch
        GraphicsDeviceManager graphics;
        SpriteBatch spriteBatch;

        // Modules and Layers
        bool wasWebcamWorking;
        AudioModule audio;
        GameLogic logic;
        InputModule input;
        CVModule cv;
        UILayer ui;
        WorldModule world;

        // CV
        int FramesCaptured = 0;
        bool IsFaceDetected = false;
        bool IsWebcamWorking = false;
        Ellipse FaceEllipse = new Ellipse();
        Vector3 HeadPos = Vector3.Zero;

        // Head position
        float FaceCentrePercentX = 0f;
        float FaceCentrePercentY = 0f;
        float FaceSizePercentWidth = 0f;
        float FaceSizePercentHeight = 0f;
        #endregion /Input Variables
        
        public CelerityGame()
        {
            // Content
            Content.RootDirectory = CeleritySettings.ContentRootDirectory;

            // Set Graphics Device
            graphics = GraphicsDeviceUtil.Create(this);

            // Modules & layers
            audio = new AudioModule();
            cv = new CVModule();
            input = new InputModule(this.Window.Handle);
            logic = new GameLogic(audio, input);
            ui = new UILayer(logic);
            world = new WorldModule(graphics, audio, input, logic);

            // Events
            ui.OnClose += (s, e) => { this.Exit(); };
        }
    }
}